package com.heima.search.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.AssonciateDto;
import com.heima.model.search.dtos.AssonciateResultDto;
import com.heima.search.mapper.AssonciateMapper;
import com.heima.search.pojos.ApAssociateWords;
import com.heima.search.service.AssonciateService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AssonciateServiceImpl extends ServiceImpl<AssonciateMapper, ApAssociateWords> implements AssonciateService {
    @Override
    public ResponseResult<List<AssonciateResultDto>> searchKeyWords(AssonciateDto dto) {

        AssonciateResultDto assonciateResultDto = new AssonciateResultDto();
       List<String> assonciateList =  this.baseMapper.selectByWord(dto.getSearchWords());
        if (assonciateList != null){
            for (String s : assonciateList) {
                assonciateResultDto.setAssociateWords(s);
                return ResponseResult.ok(dto);
            }
        }
       return ResponseResult.ok();

    }
}
